<?php

namespace App\Http\Middleware;

use Closure;

class LoginMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //中间件里写规则
        //判断用户信息是否存在
        if(empty(session('master')))
        {
            return redirect('admin/login') -> with(['info' =>'您还未登录']);
        }
        return $next($request);
    }
}
